<template>
  <div>
    <FilterTable
      ref="table"
      height="auto"
      columnsRef="partPartOutboundPartBreakCheckOutModal"
      :columns="columns"
      :datakey="'rows'"
      :onColumnsChange="columns => (this.columns = columns)"
      :onRowSelectChange="selectChange"
      :isSelectColumn="false"
      :isPagination="true"
      selectionType="single"
      :onSyncTableData="columns => (this.syncColumns = columns)"
    ></FilterTable>
    <div>
      <div>是否负库存：上述配件出入库会造成负库存，是否入账？是否库存或金额为零;</div>
      <div>1.库存数量*成本单价成本金额且库存数量或成本金额有为零；</div>
      <div>2.成本单价为零。</div>
    </div>
    <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'right'
      }"
    >
      <el-button @click="closeDrawer(1)">否</el-button>
      <AjaxButton :click="closeDrawer.bind(this, 2)" type="primary">是</AjaxButton>
    </div>
  </div>
</template>
<script>
import { checkStorage } from '@/api/part/partOutbound/partBreak';
export default {
  name: '',
  props: ['checkData'],
  data() {
    // this.BaseTable = null;
    return {
      syncColumns: [],
      columns: this.createTablelist(),
      selectedRows: [],
      fromSubmitdata: {}
    };
  },

  mounted() {
    console.log(this.checkData, '父页面查询的数据');
    this.BaseTable = this.$refs.table.$refs.pageTable;
    this.BaseTable.EXECUTE_INSERT(this.checkData);
  },
  created() {},
  methods: {
    async closeDrawer(type) {
      if (type == 1) {
        this.$emit('close', false);
      } else {
        // debugger;
        let flag = false;
        this.syncColumns.forEach(x => {
          // debugger;
          if (x.IS_NEGATIVE != 10041001) {
            return this.$notify.error({ title: '提示信息', message: '该仓库不允许负库存！' });
          } else {
            flag = true;
          }
        });
        if (flag) {
          this.$emit('change', flag);
        }
      }
    },
    createTablelist() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '仓库',
          dataIndex: 'STORAGE_CODE',
          sorter: true,
          filter: true
        },
        {
          title: '配件代码',
          dataIndex: 'PART_NO',
          sorter: true,
          filter: true
        },
        {
          title: '配件名称',
          dataIndex: 'PART_NAME',
          sorter: true,
          filter: true
        },
        {
          title: '是否库存或金额为零',
          dataIndex: 'ISNORMAL',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.ISNORMAL === '10041001' ? '是' : '否'}</span>;
          }
        },
        {
          title: '是否负库存',
          dataIndex: 'ISNEGATIVE',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.ISNEGATIVE === '10041001' ? '是' : '否'}</span>;
          }
        },
        {
          title: '是否允许负库存',
          dataIndex: 'IS_NEGATIVE',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.ISNEGATIVE === '10041001' ? '是' : '否'}</span>;
          }
        },
        {
          title: '可用库存',
          dataIndex: 'USEABLE_STOCK',
          sorter: true,
          filter: true
        },
        {
          title: '出库数量',
          dataIndex: 'PART_QUANTITY',
          sorter: true,
          filter: true
        },
        {
          title: '锁定数量',
          dataIndex: 'LOCKED_QUANTITY',
          sorter: true,
          filter: true
        }
      ];
    },

    // 选中
    selectChange(rows) {
      this.selectedRows = rows;
    }
  }
};
</script>
